package com.youkeyi.ddy.cloud.common.response;

/**
 * <p>
 *  结果返回包装
 * </p>
 *
 * @author 23.1
 * @since 2020-05-11
 */
public class ResponseContent {

    public ResponseContent() {
        this.success = Boolean.TRUE;
        this.code = SUCCESS_CODE;
    }

    public ResponseContent(boolean success, String message) {
        this.success = success;
        this.code = ERROR_CODE;
        if (success) {
            this.code = SUCCESS_CODE;
        }
        this.message = message;
    }

    private static final Integer SUCCESS_CODE = 10000;
    private static final Integer ERROR_CODE = 0;

    /**
     * 执行是否成功
     */
    private boolean success;
    /**
     * 执行结果码
     */
    private Integer code;
    /**
     * 响应携带消息
     */
    private String message;
    /**
     * 响应携带业务主键
     */
    private String key;

    public void setSuccessMessage(String message) {
        this.success = Boolean.TRUE;
        this.message = message;
        this.code = SUCCESS_CODE;
    }


    public void setErrorMessage(String message) {
        this.success = Boolean.FALSE;
        this.message = message;
        this.code = ERROR_CODE;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}
